import "reflect-metadata";
interface ControllerOptions {
  prefix?: string;
}
export function Controller(): ClassDecorator; //传空串
export function Controller(prefix: string): ClassDecorator; //路径前缀
export function Controller(options: any): ClassDecorator; //配置对象
export function Controller(
  prefixOptions?: string | ControllerOptions
): ClassDecorator {
  let options: ControllerOptions = {};
  if (typeof prefixOptions === "string") {
    options.prefix = prefixOptions;
  } else if (typeof prefixOptions === "object") {
    options = prefixOptions;
  }
  //这是一个类控制器 装饰的控制器这个类
  return (target: Function) => {
    //给控制器类添加perfix路径前缀的元数据
    Reflect.defineMetadata("prefix", options.prefix, target);
  };
}
